function error_x = calculate_error(delta_l, DH_para, x_real, Q)
[n, ~] = size(Q);

Alpha = DH_para.Alpha;
A = DH_para.A;
D = DH_para.D;
Theta = DH_para.Theta;
D(1) = D(1) + delta_l(1);
A(3) = A(3) + delta_l(2);
A(4) = A(4) + delta_l(3);
D(4) = D(4) + delta_l(4);
D(5) = D(5) + delta_l(5);
D(6) = D(6) + delta_l(6);

for i = 1:6
    L(i) = Link('alpha',Alpha(i),'a', A(i),'d', D(i)); L(i).offset = Theta(i); L(i).qlim=[-pi, pi]; L(i).mdh = 1;
end

robot = SerialLink(L, 'name', 'UR');
for i = 1:n
    qi = Q(i, :);
    x_th(3*i-2:3*i, 1) = robot.fkine(qi).t;
end
error_x = x_real - x_th;